#ifndef DATA_DEVICE_H
#define DATA_DEVICE_H

class dataDevice
{
public:
  int fd;
	virtual bool open() = 0;
	virtual ssize_t read(void *buffer, size_t size) = 0;
	virtual ssize_t write(const void *buffer, size_t size) = 0;
};

class ethernetDataDevice : public dataDevice
{
	char const * addr;
	int port;

public:
	//int sockfd;
	ethernetDataDevice(char const * addr, int port);
	bool open();
	ssize_t read(void *buffer, size_t size);
	ssize_t write(const void *buffer, size_t size);
	~ethernetDataDevice();
};

class serialDataDevice : public dataDevice
{
	//int fd;
	char const * serialName;

public:
  serialDataDevice(char const * serialName);
	bool open();
	ssize_t read(void *buffer, size_t size);
	ssize_t readn(void *buffer, size_t size);
	ssize_t write(const void *buffer, size_t size);
	~serialDataDevice();
};

#endif  //DATA_DEVICE_H
